

pub struct Application {
    resource_path: String,
    title: String,
    width: u32,
    height: u32,
    // canvas: Option<Canvas<Window>>,
    // sdl_context: Option<sdl2::Sdl>,

}

impl Application {
    pub fn new(path: &str) -> Application {
        Application {
            resource_path: path.to_string(),
            width: 0,
            height: 0,
            // canvas: None,
            // sdl_context: None,
            title: "SDL Window".to_string(),
        }
    }

    pub fn init(&mut self, title: &str, width:u32, height:u32) {
        self.title = title.to_string();
        self.width = width;
        self.height = height;
        //创建窗口

        // self.sdl_context = Some(sdl2::init().unwrap());
        // let video_subsystem = self.sdl_context.as_ref().expect("sdl_context invalid !").video().unwrap();

        // let window = video_subsystem
        //     .window(self.title.as_str(), self.width, self.height)
        //     .position_centered()
        //     .opengl()
        //     .build()
        //     .unwrap();

        // self.canvas = Some(window.into_canvas().build().unwrap());
    }

    pub fn run(&mut self) {
        // let canvas = self.canvas.as_mut().expect("canvas invalid !");
        // let sdl_context = self.sdl_context.as_mut().expect("sdl_context invalid !");

        // canvas.set_draw_color(Color::RGB(0, 255, 255));
        // canvas.clear();
        // canvas.present();
        // let mut event_pump = sdl_context.event_pump().unwrap();
        // let mut i = 0;
        // 'running: loop {
        //     i = (i + 1) % 255;
        //     canvas.set_draw_color(Color::RGB(i, 64, 255 - i));
        //     canvas.clear();
        //     for event in event_pump.poll_iter() {
        //         match event {
        //             Event::Quit { .. }
        //             | Event::KeyDown {
        //                 keycode: Some(Keycode::Escape),
        //                 ..
        //             } => break 'running,
        //             _ => {}
        //         }
        //     }
        //     // The rest of the game loop goes here...

        //     canvas.present();
        //     ::std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 60));
        // }
    }
}
